/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘远望
 * Date: 2025-03-12
 * Time: 22:11
 */
//类和对象
//  类是class+对象名
class Dog{
    //字段   属性   成员变量
    //基本类型自动初始化为对应的0值
    //引用类型初始化为null
    public String name;
    public int age;
    //成员方法
    public void eat(){
        System.out.println("吃东西的方法");
    }
}
public class Test {
    public static void main(String[] args) {
        Dog dog1 = new Dog();
        //实例化
        dog1.name = "小黑";
        dog1.age = 2;
        System.out.println(dog1.name);
        System.out.println(dog1.age);
        Dog dog2 = new Dog();
        dog2.name = "小黄";
        dog2.age = 3;
        System.out.println(dog2.name);
        System.out.println(dog2.age);
    }
}
